<template>
  <div class="mx-content">
    <div style="height: 80px"></div>
    <div class="flex notice-content-wrap">
      <div class="notice-content">
        <div class="notice-title">
          <h5 class="notice-name">
            {{detail.title}}
          </h5>
          <div class="notice-subtitle flex flexAC">
            <p>首页</p>
            <i class="iconfont icon-a-tubiaoright"></i>
            <p>新闻资讯</p>
            <p class="flex flexAC">
              <i class="iconfont icon-time"></i> {{detail.gmtCreate}}
            </p>
          </div>
          
        </div>
        <div class="notice-text v-html-content" v-html="detail.description"></div>
      </div>
      <div class="notice-hot">
        <h5 class="notice-hot-title">热门新闻</h5>
        <div class="notice-hot-content">
          <ul>
            <li class="flex" v-for="it in list" :key="it.id" @click="handleToNews(it)">
              <img :src="`${qiniu}/${it.url}`" alt="" />
              <div class="hot-right">
                <h5 class="ellipsis">{{it.title}}</h5>
                <span>{{it.gmtCreate}}</span>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { news_detail, news_listR } from '@/api/system';
import { mapGetters } from 'vuex';

export default {
  data() {
    return {
      id:this.$route.query.id,
      list:[],
      detail:{}
    };
  },

  components: {},
  props: {},
  mounted() {
    window.scroll(0, 0);
    this.$store.dispatch('other/setIndex',3)
    this.getDetail();
    this.getHot();
  },
  computed: {
    ...mapGetters({ qiniu: "qiniu" })
  },
  watch: {},
  methods: {
    getDetail(){
      let self = this;
      news_detail({newsId:self.id})
      .then(res=>{
        self.detail = res.data;
      })
    },
    getHot(){
      let self = this;
      news_listR({page:1,limit:5})
      .then(res=>{
        self.list = res.data.records;
      })
    },
    handleToNews(it) {
      console.log(11111111)
      if(it.id ==  this.id) return false;
      this.$router.push({ path: "/notice", query: { id: it.id } });
      this.id = it.id
      this.getDetail(it.id)
      window.scroll(0, 0);
    },
  },
  destroyed() {},
};
</script>
<style lang='scss' scoped>
@import "@/style/variables.scss";

.notice-content-wrap {
  padding-top: 48px;
  min-height: calc(100vh - 460px);
  .notice-content {
    width: 70%;
    .notice-title {
      padding-bottom: 10px;
      border-bottom: 1px solid $modal;
      .notice-name {
        font-size: $fsH2;
        margin-bottom: 16px;
      }
      .notice-subtitle {
        font-size: 12px;
        i {
          font-size: 16px;
          margin: 0 12px;
          &:last-child {
            margin-right: 5px;
          }
        }
      }
    }
  }
  .hot-right{
    width: 190px;
  }
  .notice-text{
    padding: 24px 0;
    min-height: 400px;
  }
  .notice-hot {
    width: 30%;
    padding-left: 48px;
    .notice-hot-title {
      line-height: 24px;
      font-size: $fsH5;
      margin: 0;
      padding-bottom: 24px;
      border-bottom: 1px solid $modal;
    }
    .notice-hot-content {
      padding-bottom:24px;
      ul {
        li {
          margin-top: 24px;
          cursor: pointer;
          &:hover{
            h5{
              color: $primary;
            }
          }
          img {
            width: 102px;
            height: 64px;
            border-radius: 4px;
          }
          .hot-right{
              margin-left: 16px;
              display: flex;
              flex-direction: column;
              justify-content: space-between;
          }
        }
      }
    }
  }
}
@media screen and (max-width: 768px) {
  .notice-content-wrap{
    flex-direction: column;
    padding-top: 0;
    .notice-content{
      width: 100%;
      .notice-title{
        .notice-name{
          font-size: .48rem;
        }
        .notice-subtitle{
          font-size: .32rem;
          i{
            margin: 0 .2rem;
          }
        }
      }
      
      .notice-text{
        padding: .42rem 0 .8rem;
      }
    }
    .notice-hot{
      width: 100%;
      padding-left: 0;
      .notice-hot-title{
        padding-bottom: .42rem;
      }
      .notice-hot-content{
        ul{
          li{
            img{
              width: 2.8rem;
              height: 1.575rem;
            }
            .hot-right{
              width: calc(6.4rem - 16px);
            }
          }
        }
      }
    }
  }
}
</style>